define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'membess/index' + location.search,
                    add_url: 'membess/add',
                    edit_url: 'membess/edit',
                    del_url: 'membess/del',
                    multi_url: 'membess/multi',
                    import_url: 'membess/import',
                    table: 'membe_s',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'membe_id',
                sortName: 'membe_id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'membe_id', title: __('Membe_id')},
                        {field: 'dream_id', title: __('Dream_id')},
                        {field: 'username', title: __('Username'), operate: 'LIKE'},
                        {field: 'openid', title: __('Openid'), operate: 'LIKE'},
                        {field: 'wx_openid', title: __('Wx_openid'), operate: 'LIKE'},
                        {field: 'wx_app_openid', title: __('Wx_app_openid'), operate: 'LIKE'},
                        {field: 'sex', title: __('Sex')},
                        {field: 'pic', title: __('Pic'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'email', title: __('Email'), operate: 'LIKE'},
                        {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'password', title: __('Password'), operate: 'LIKE'},
                        {field: 'bg_image', title: __('Bg_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'fans_num', title: __('Fans_num')},
                        {field: 'follow_num', title: __('Follow_num')},
                        {field: 'star_num', title: __('Star_num')},
                        {field: 'user_exp', title: __('User_exp')},
                        {field: 'writer_exp', title: __('Writer_exp')},
                        {field: 'wallet', title: __('Wallet'), operate:'BETWEEN'},
                        {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'commission', title: __('Commission'), operate:'BETWEEN'},
                        {field: 'with_drawable', title: __('With_drawable'), operate:'BETWEEN'},
                        {field: 'ssq', title: __('Ssq'), operate: 'LIKE'},
                        {field: 'tinymce', title: __('Tinymce')},
                        {field: 'tinymce2', title: __('Tinymce2')},
                        {field: 'is_vip', title: __('Is_vip')},
                        {field: 'is_writer', title: __('Is_writer')},
                        {field: 'is_home_label', title: __('Is_home_label')},
                        {field: 'home_label_type', title: __('Home_label_type')},
                        {field: 'home_label_one', title: __('Home_label_one'), operate: 'LIKE'},
                        {field: 'home_label_two', title: __('Home_label_two'), operate: 'LIKE'},
                        {field: 'home_label_bg_color', title: __('Home_label_bg_color'), operate: 'LIKE'},
                        {field: 'home_label_bg_img', title: __('Home_label_bg_img'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'status', title: __('Status')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'id_name', title: __('Id_name'), operate: 'LIKE'},
                        {field: 'id_card', title: __('Id_card'), operate: 'LIKE'},
                        {field: 'id_sex', title: __('Id_sex'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'is_auth', title: __('Is_auth')},
                        {field: 'shengri', title: __('Shengri'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'is_auth_time', title: __('Is_auth_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'is_shuiyin', title: __('Is_shuiyin')},
                        {field: 'is_fensi', title: __('Is_fensi')},
                        {field: 'is_gaunzhu', title: __('Is_gaunzhu')},
                        {field: 'is_tuijian', title: __('Is_tuijian')},
                        {field: 'is_primsg', title: __('Is_primsg')},
                        {field: 'unionId', title: __('Unionid'), operate: 'LIKE'},
                        {field: 'is_pai', title: __('Is_pai')},
                        {field: 'pai_time', title: __('Pai_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'dream', title: __('Dream')},
                        {field: 'tuan_id', title: __('Tuan_id')},
                        {field: 'u_level', title: __('U_level')},
                        {field: 'w_level', title: __('W_level')},
                        {field: 'tag_ids', title: __('Tag_ids'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'q_flag', title: __('Q_flag'), formatter: Table.api.formatter.flag},
                        {field: 'sel_nick', title: __('Sel_nick')},
                        {field: 'sel_dream', title: __('Sel_dream')},
                        {field: 'sel_fens', title: __('Sel_fens')},
                        {field: 'sel_guan', title: __('Sel_guan')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
